﻿using System;
using MugenInjection.Delegates;
using MugenInjection.Interface;

namespace MugenInjection.Infrastructure
{
    /// <summary>
    ///     Represents the context that converter uses to create convert an instance.
    /// </summary>
    public sealed class ConverterContext
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="ConverterContext" /> class.
        /// </summary>
        public ConverterContext(IBindingContext bindingContext, Func<IBindingContext, object> activator,
                                IBinding binding, bool isFixed)
        {
            BindingContext = bindingContext;
            Activator = activator;
            Binding = binding;
            IsFixed = isFixed;
        }

        /// <summary>
        ///     Initializes a new instance of the <see cref="ConverterContext" /> class.
        /// </summary>
        public ConverterContext(ConverterContext innerContext)
        {
            BindingContext = innerContext.BindingContext;
            Activator = innerContext.Activator;
            Binding = innerContext.Binding;
            IsFixed = innerContext.IsFixed;
        }

        #endregion

        #region Properties

        /// <summary>
        ///     Gets or sets a delegate to create service.
        /// </summary>
        public Func<IBindingContext, object> Activator { get; set; }

        /// <summary>
        ///     Gets or sets a binding context to create service.
        /// </summary>
        public IBindingContext BindingContext { get; set; }

        /// <summary>
        ///     Gets or sets the binding to create service.
        /// </summary>
        public IBinding Binding { get; set; }

        /// <summary>
        ///     Gets or sets value that indicates that context contains fixed value.
        /// </summary>
        public bool IsFixed { get; set; }

        #endregion
    }
}